package com.luo.graduatedesign.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DataBaseConnect {

	private static final String JDBC_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
	private static final String DB_URL = "jdbc:odbc:driver={Microsoft Access Driver (*.accdb)};DBQ=database/systemdb.accdb";

	static {
		try {
			Class.forName(JDBC_DRIVER);
		} catch (ClassNotFoundException ce) {
			ce.printStackTrace();
		}
	}

	private static DataBaseConnect DBC;
	
	private DataBaseConnect() {
		
	}

	public Connection getConnection() {
		try {
			Connection conn = DriverManager.getConnection(DB_URL);
		} catch (SQLException se) {
			se.printStackTrace();
		}
		return null;
	}

	public void freeDBConnect(Connection connection, Statement statement,
			ResultSet resultSet) {
		try {
			if (resultSet != null) {
				resultSet.close();
			}
		} catch (SQLException re) {
			re.printStackTrace();
		} finally {
			try {
				if (statement != null) {
					statement.close();
				}
			} catch (SQLException se) {
				se.printStackTrace();
			} finally {
				if (connection != null) {
					try {
						connection.close();
					} catch (SQLException ce) {
						ce.printStackTrace();
					}
				}
			}
		}
	}
}
